The goal of the present paper is to provide a mathematically rigorous foundation to certain aspects of rational orbifold conformal field theory, in other words the theory of rational vertex operator algebras and their automorphisms. Under a certain finiteness condition on a rational vertex operator algebra V which holds in all known examples, we determine the precise numbers of g-twisted sectors for any automorphism g of V of finite order. We prove that the trace functions and correlations functions associated with such twisted sectors are holomorphic functions in the upper half-plane and, under suitable conditions, afford a representations of the modular group of the type prescribed in string theory. We establish the rationality of conformal weights and central charge. In addition to conformal field theory itself, where our conclusions are required on physical grounds, there are applications to the generalized Moonshine conjectures of Conway-Norton-Queen and to equivariant elliptic cohomology.